const http = require('http');
const querystring = require('querystring');
let server = http.createServer((req,res) => {
    const query = querystring.parse(req.url.split('?')[1]);
    console.log(query);

    const {name,age,callback} = query;
    // const data = {
    //     name:name,
    //     age:age
    // }
    const data = `window.alert('你被黑了');`;
    res.statusCode = 200
    res.setHeader('Content-Type', 'text/plain')
    console.log(JSON.stringify(data));
    res.end(`${callback}(${JSON.stringify(data)})`);
    // res.end(`${callback}(${JSON.stringify(data)})`);


})

server.listen(3000,()=> {

    console.log('服务启动了');
})